package cn.bdqn.appinfo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bdqn.appinfo.entity.AppCategory;
import cn.bdqn.appinfo.entity.AppInfo;
import cn.bdqn.appinfo.mapper.AppCategoryMapper;
import cn.bdqn.appinfo.mapper.AppInfoMapper;
import cn.bdqn.appinfo.util.Page;

@Service
public class AppInfoServiceImpl implements AppInfoService {
	@Autowired private AppCategoryMapper categoryMapper;
	@Autowired private AppInfoMapper appInfoMapper;
	
	@Override
	public List<AppCategory> findAppCategoryByParentId(Integer id) throws Exception {
		return categoryMapper.getAppCategoryListByParentId(id);
	}

	@Override
	public void find(AppInfo appInfo, Page<AppInfo> page) {
		int totalCount = appInfoMapper.findAppInfoCount(appInfo);
		//设置总记录数和总页数
		page.setTotalCount(totalCount);
		//设置分好页的数据集合
		List<AppInfo> dataList = appInfoMapper.findAppInfo(appInfo, (page.getPageNo() - 1) * page.getPageSize(), page.getPageSize());
		page.setDataList(dataList);
	}

}
